package com.yuzhyn.hiops.app.system.config;

import com.yuzhyn.hiops.app.system.interceptor.Interceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
/**
 * WebMvc增加拦截器配置
 */
@Configuration
public class AppWebMvcConfig implements WebMvcConfigurer {

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        // 身份信息及url权限
//        registry.addInterceptor(new SecurityInterceptor()).addPathPatterns("/**");
        // 实现跨域
        registry.addInterceptor(new Interceptor()).addPathPatterns("/**");
        // 日志记录
//        registry.addInterceptor(new LogInterceptor()).addPathPatterns("/**");
    }

//    @Override
//    public void addResourceHandlers(ResourceHandlerRegistry registry) {
//        registry.addResourceHandler(new String[]{"/templates/**.js"}).addResourceLocations(new String[]{"classpath:/templates/"});
//        registry.addResourceHandler(new String[]{"/templates/**.css"}).addResourceLocations(new String[]{"classpath:/templates/"});
//        registry.addResourceHandler(new String[]{"/static/**"}).addResourceLocations(new String[]{"classpath:/static/"});
//        registry.addResourceHandler(new String[]{"swagger-ui.html"}).addResourceLocations(new String[]{"classpath:/META-INF/resources/"});
//        registry.addResourceHandler(new String[]{"/webjars/**"}).addResourceLocations(new String[]{"classpath:/META-INF/resources/webjars/"});
//    }
}